#define _CRT_SECURE_NO_WARNINGS
#include "12.3_hs.h"

void set_stu(struct stu* s)
{
	/*s->id[0] = 2;
	s->id[1] = 3;
	s->id[2] = 4;
	s->id[3] = 5;
	s->n = 10;*/
	(*s).id[0] = 4;
	(*s).id[1] = 5;
	(*s).id[2] = 6;
	(*s).id[3] = 7;
	(*s).n = 7;
}

void Print_stu(struct stu* s, int sz)
{
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", s->id[i]);
	}
	printf("%cn = %d\n", 10, s->n);
}

int cmp_zfsz_asc(const void* e1, const void* e2)
{
	return *((char*)e1) - *((char*)e2);
}

void Swap(char* e1, char* e2, int width)
{
	for (int i = 0; i < width; i++)
	{
		char t = *(e1 + i);
		*(e1 + i) = *(e2 + i);
		*(e2 + i) = t;
	}
}

void mppx_qsort(const void* base, size_t sz, size_t width, int(*cmp)(const void*, const void*))
{
	for (int i = 0; i < sz - 1; i++)
	{
		int flag = 1;
		for (int j = 0; j < sz - 1 - i; j++)
		{
			if (cmp((char*)base + (j * width), (char*)base + (j + 1)*width) > 0)
			{
				Swap((char*)base + (j * width), (char*)base + (j + 1)* width, width);
			}
		}
	}
}

void Print_zfsz(char* zf, size_t sz)
{
	for (int j = 0; j < sz; j++)
	{
		printf("%c ", *(zf + j));
	}
	printf("\n");
}

void Print_intsz(int(*num)[3], int row, int col)
{
	for (int r = 0; r < row; r++)
	{
		for (int c = 0; c < col; c++)
		{
			//printf("%d ", *(*(num + r) + c));
			printf("%d ", num[r][c]);
		}
		printf("%c", 10);
	}
}